圖片來源:https://wandb.ai/site
如何在Python開發環境使用,以及程式碼需要如何撰寫:
工具安裝:
pip install wandb -qU
登入後,點選https://wandb.ai/authorize 取得 API key
程式碼撰寫:(以一個簡易的資料做示範)
當程式執行到 wandb.login()時,會出現以下選擇,因為上一步已經先申請好帳號,所以這邊選 2
接下來會要求輸入API key,API key的取得方式可以參考以上第二步
import wandb
wandb.login()
import random
# Launch 5 simulated experiments
total_runs = 5
for run in range(total_runs):
# Start a new run to track this script
wandb.init(
# Set the project where this run will be logged
project="basic-intro",
# We pass a run name (otherwise it’ll be randomly assigned, like sunshine-lollypop-10)
name=f"experiment_{run}",
# Track hyperparameters and run metadata
config={
"learning_rate": 0.02,
"architecture": "CNN",
"dataset": "CIFAR-100",
"epochs": 10,
})
# This simple block simulates a training loop logging metrics
epochs = 10
offset = random.random() / 5
for epoch in range(2, epochs):
acc = 1 - 2 ** -epoch - random.random() / epoch - offset
loss = 2 ** -epoch + random.random() / epoch + offset
# Log metrics from your script to W&B
wandb.log({"acc": acc, "loss": loss})
# Mark the run as finished
wandb.finish()
圖:Weight&Biases 結果
參考文獻
1.初探mlflow-tracking-保持ml實驗的可追溯性與可重現性-
2.Weights & Biases — ML 實驗數據追蹤
(撰稿工程師:顧祥龍)
完整內容 >> https://bit.ly/3AbUo0N
Line 官方帳號,看最新技術文章:https://user137910.pse.is/aif2024ironman